#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author:Zhangcl
from core import user_login
from core.student import Student_run
from core.teacher import Teacher_run
from core.admin import Admin_run
class User():
    def __init__(self):
       pass
    def user_choise(self):
        choise_menu='''\033[1;31m
        ---------Welcome----------
        1. 学员登录
        2. 教师登录
        3. 管理员登录
        4. 退出\033[0m
        '''
        menu_dict = {
            '1':'students',
            '2':'teacher',
            '3':'admin',
            '4':'loginout'
        }
        run_dict={
            'students':Student_run,
            'teacher':Teacher_run,
            'admin':Admin_run
        }

        while True:
            print(choise_menu)
            login_choise=input('请选择>>>>').strip()
            if login_choise in menu_dict:
                if int(login_choise) == 4:
                    exit()
                else:
                    login_user=input('请输入账户>>>')
                    login_passwd = input('请输入密码>>>')
                    login_obj = user_login.User_login(login_user,login_passwd,menu_dict[login_choise])#将账户密码及账户类型传送给登录模块
                    run =login_obj.type_choise()
                    if run: #如果返回ture，说明账户密码验证正确，执行对应模块下面的程序
                        run_dict[run](login_user).menu()
            else:
                print('输入错误！')